#pragma once

#include <thread>
#include <mutex>
#include <string>
#include <condition_variable>
#include "EventLoop.h"

class WorkerThread
{
public:
    WorkerThread(int index);
    ~WorkerThread();
    // 启动线程
    void run();
    inline EventLoop* getEventLoop()
    {
        return m_evLoop;
    }

private:
    void running();

private:
    std::thread *m_thread;
    std::thread::id m_threadID;
    std::string m_name;
    std::mutex m_mutex;    // 互斥锁
    std::condition_variable m_cond;     // 条件变量
    EventLoop *m_evLoop; // 反应堆模型
};
